package leetcode.bfs;

import leetcode.bfs.common.BFSUtils;
import leetcode.dfs.common.DFSUtils;
import leetcode.tree.common.TreeNode;
import leetcode.tree.common.TreeUtils;

/**
 * Definition for a binary tree node.
 * public class TreeNode {
 * int val;
 * TreeNode left;
 * TreeNode right;
 * TreeNode() {}
 * TreeNode(int val) { this.val = val; }
 * TreeNode(int val, TreeNode left, TreeNode right) {
 * this.val = val;
 * this.left = left;
 * this.right = right;
 * }
 * }
 */
class Solution617 {
    public TreeNode mergeTrees(TreeNode root1, TreeNode root2) {
        return BFSUtils.mergeTrees(root1, root2);
//        return DFSUtils.mergeTrees(root1, root2);
    }
}

public class leetcode617 {
    public static void main(String[] args) {
        Solution617 solution617 = new Solution617();
        Integer[] nums1 = {1, 3, 2, 5};
        Integer[] nums2 = {2, 1, 3, null, 4, null, 7};
        test617(solution617, nums1, nums2);

        Integer[] nums3 = {1, 2, null, 3};
        Integer[] nums4 = {1, null, 2, null, 3};
        test617(solution617, nums3, nums4);

    }

    private static void test617(Solution617 solution617, Integer[] nums1, Integer[] nums2) {
        TreeNode root = solution617.mergeTrees(TreeUtils.generateLeetcodeTree(nums1), TreeUtils.generateLeetcodeTree(nums2));
        System.out.println(TreeUtils.getLeetcodeTreeVals(root));
    }
}
